﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Weazel.Gezel.Model.Errors
{
  public enum ParseErrorType
  {   
    /// <summary>
    /// The left hand side of an assignment expression
    /// is invalid (ie. not an identifier).
    /// </summary>
    InvalidAssignmentLeftExpression,

    /// <summary>
    /// An unexpected token was encountered where
    /// a single specific token was expected.
    /// </summary>
    UnexpectedTokenExpectedSingle,

    /// <summary>
    /// An unexpected token was encountered where
    /// multipe specific tokens were expected.
    /// </summary>
    UnexpectedTokenExpectedMultiple,

    /// <summary>
    /// Name of a register, signal or port has been used multiple
    /// times in the same datapath
    /// </summary>
    DuplicateSymbolDefintion,

    /// <summary>
    /// Two or more sfg's has the same name
    /// </summary>
    DuplicateSfgDefinition,

    /// <summary>
    /// Name of dp or controller is not unique..
    /// </summary>
    DuplicateDatapathDefintion,
    DuplicateControllerDefinition,

    /// <summary>
    /// Two or more transitions has the same source state   
    /// </summary>
    DuplicateTranstion,

    /// <summary>
    /// More than one 'iptype' found in Ipblock
    /// </summary>
    DuplicateIpType,

    /// <summary>
    /// Empty sfg lists are not allowed in fsm transitions
    /// </summary>
    EmptySfgList,

    /// <summary>
    /// Two or more 'initial' states found in fsm
    /// </summary>
    DuplicateInitialState,

    /// <summary>
    ///  A state has been defined several times
    /// </summary>
    DuplicateStateDefintion,

    /// <summary>
    /// A constant name has already been used
    /// </summary>
    DuplicateConstantDefinition,

    /// <summary>
    /// A newline has been found in a string. 
    /// Usually means that the ending " is missing
    /// </summary>
    NewlineInString,

    
    /// <summary>
    /// Tokenizer encountered an "unknown" character
    /// </summary>
    UnknownInputCharacter
  };

  public class ParseError : Error
  {
    private ParseErrorType errorType;

    #region Properties
    public ParseErrorType ErrorType
    {
      get
      {
        return errorType;
      }
    }
    #endregion

    public ParseError(ParseErrorType errorType, ErrorMessage message) : base(message)
    {
      this.errorType = errorType;
    }

    protected ParseError(ParseErrorType errorType) 
    {
      this.errorType = errorType;
    }

    public override string ToString()
    {
      return errorMessage.ToString();
    }
  }
}
